﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class search : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            //if (HiddenField_sortSelect.Value == "")
            //{
            //    menu("1");
                //HiddenField_sortSelect.Value = "1";
            Validator1.Enabled = true;
            Validator1.Visible = true;

            //}
        }
       this.todayReportNoLb.Text= getTodayReportNum().ToString();


    }
    protected void Button_search_Click(object sender, EventArgs e)
    {
        string url = "detail.aspx?sel=" + DropDownList_type.SelectedValue.Trim() + "&keyword=" + TextBox_input.Text;
        Response.Redirect(url);

    }
    protected void Button_report_Click(object sender, EventArgs e)
    {
        string url = "report.aspx?sel=" + DropDownList_type.SelectedValue.Trim() + "&keyword=" + TextBox_input.Text;
        Response.Redirect(url);
    }
    protected void DropDownList_type_SelectedIndexChanged(object sender, EventArgs e)
    {

        if (DropDownList_type.SelectedValue == "1")
        {
            Validator1.Enabled = true;
            Validator1.Visible = true;
        }
        else if (DropDownList_type.SelectedValue == "2")
        {
            Validator2.Enabled = true;
            Validator2.Visible = true;
        }else if (DropDownList_type.SelectedValue == "3")
        {
            Validator3.Enabled = true;
            Validator3.Visible = true;
        }
        else if (DropDownList_type.SelectedValue == "4")
        {
            Validator4.Enabled = true;
            Validator4.Visible = true;
        }
        else if (DropDownList_type.SelectedValue == "5")
        {
            Validator5.Enabled = true;
            Validator5.Visible = true;
        }
        else if (DropDownList_type.SelectedValue == "6")
        {
            Validator6.Enabled = true;
            Validator6.Visible = true;
        }
        else if (DropDownList_type.SelectedValue == "7")
        {
            Validator0.Enabled = true;
            Validator0.Visible = true;
        }
            else if (DropDownList_type.SelectedValue == "8")
            {
                Validator0.Enabled = true;
                Validator0.Visible = true;
            }
            //else
            //{
            //    Validator1.Enabled = true;
            //    Validator1.Visible = true;
            //}
    }

    public int getTodayReportNum()
    {
        string sql = " select COUNT(*) as num from Dyh_baseDB where DateDiff(dd,L_R_time,getdate())=0   ";
        string str = System.Configuration.ConfigurationManager.ConnectionStrings["decheatConnectionString"].ToString();
        int num = 0;
        SqlConnection conn = new SqlConnection(str);
        conn.Open();
        SqlCommand comm = new SqlCommand(sql, conn);
        System.Data.DataSet ds = new DataSet();
        SqlDataReader dr = comm.ExecuteReader();
        while (dr.Read())
        {
            num = int.Parse(dr["num"].ToString());
        }
        dr.Close();
        if (conn.State == ConnectionState.Open)
            conn.Close();
        return num;

    }
}
